﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using BrokerBase.Lib.Policy;
using BrokerBase.Lib.Person;

namespace Broker.View.PolicyView
{
    public delegate void PersonChangedHandler(PersonType personType,IScheme scheme);

    public class SchemeHeadUserControl:UserControl
    {
        public event PersonChangedHandler PersonChanged;

        private IScheme scheme;

        public ContentControl Owner { get; set; }

        public SchemeHeadUserControl()
            : base()
        {

        }

        public virtual void OnScheme_Chagned()
        {

        }

        public SchemeHeadUserControl(IScheme scheme)
            :this()
        {
            this.scheme = scheme;

            Loaded += new System.Windows.RoutedEventHandler(PolicyHeadUserControl_Loaded);
        }

        void PolicyHeadUserControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            DataContext = scheme;
        }

        protected IScheme Scheme { get { return scheme; } }

        public virtual void SetControlState(IScheme scheme)
        {

        }

        protected void RaisePersonChanged(PersonType personType,IScheme scheme)
        {
            if (PersonChanged != null)
            {
                PersonChanged(personType, scheme);
            }
        }
    }
}
